/**
 * 书籍管理
 * @project readnote
 * @author huxh
 * @date 2012-5-15
 **/
package com.readnote.admin.book;

import java.io.File;

import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;

import com.cr.backbone.action.AppBaseActionSupport;
import com.cr.backbone.model.SysFile;
import com.readnote.book.model.Book;
import com.readnote.book.service.BookService;

public class BookManageAction extends AppBaseActionSupport{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1179031234511250745L;
	
	private Long[] ids;//数据更新主键集合
	private Book book;

	
	private BookService bookService;
	
	/***
	 * 查看 book list
	 */
	public String index(){
		page = bookService.getPage(getQuery(), page);
		return INDEX;
	}
	
	/***
	 * 查看 book list
	 */
	public String query(){
		page = bookService.getPage(getQuery(), page);
		return INDEX;
	}
	
	/**
	 * 进入book更新页面
	 */
	public String input(){
		if(ids!=null && ids.length!=0)
			book = bookService.get(ids[0]);
		return INPUT;
	}
	
	/**
	 * 保存（新建\更新）
	 * @methodDescribe 
	 * @return
	 * @author xianghua.hu
	 * @date 2012-5-15
	 */
	public String save(){
		if(book==null || book.isNullRow()){
			bookService.save(book);
		}else{
			Book _book = bookService.get( book.getId() );
			
			bookService.update(_book);
		}
		return SUCCESS;
	}

	public Long[] getIds() {
		return ids;
	}

	public void setIds(Long[] ids) {
		this.ids = ids;
	}

	public Book getBook() {
		return book;
	}

	public void setBook(Book book) {
		this.book = book;
	}

	public BookService getBookService() {
		return bookService;
	}

	public void setBookService(BookService bookService) {
		this.bookService = bookService;
	}
	
	

	
}
